package com.wx.wechat.Interface;

import com.wx.wechat.response.WeChatCode2Session;
import com.wx.wechat.response.WeChatOauth2AccessToken;
import com.wx.wechat.response.WeChatUser;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

import java.util.Map;

import static com.wx.wechat.config.WechatAPI.CONNECT_OAUTH2_AUTHORIZE_URL;
import static com.wx.wechat.constant.WechatParameterName.WechatRequest.REQUEST_ACCESS_TOKEN;
import static com.wx.wechat.constant.WechatParameterName.WechatRequest.REQUEST_OPEN_ID;

/**
 * @author wx
 * @Description: 微信授权请求
 * @date 2018/11/6 000612:10
 */
public interface WeChatOatuh {
    /**
     * @description: 微信oauth2授权
     * @author: wx
     * @date: 2018/11/6 0006
     * @param parameMap
     * @return: retrofit2.Call<java.lang.String>
     */
    @GET(CONNECT_OAUTH2_AUTHORIZE_URL)
    Call<String> oauth2buildAuthorizationUrl(@QueryMap Map<String, String> parameMap);
    
    /**
     * @description: 获取AccessToken
     * @author: wx
     * @date: 2018/11/6 0006
     * @param parameMap
     * @return: retrofit2.Call<com.wx.wechat.response.WechatMpOauth2AccessToken>
     */
    @GET("/sns/oauth2/access_token")
    Call<WeChatOauth2AccessToken> oauth2getAccessToken(@QueryMap Map<String, String> parameMap);
    
    /**
     * @description: 刷新AccessToken
     * @author: wx
     * @date: 2018/11/6 0006
     * @param parameMap
     * @return: retrofit2.Call<com.wx.wechat.response.WechatMpOauth2AccessToken>
     */
    @GET("/sns/oauth2/refresh_token")
    Call<WeChatOauth2AccessToken> oauth2refreshAccessToken(@QueryMap Map<String, String> parameMap);
    /**
     * @description: 获取微信用户信息
     * @author: wx
     * @date: 2018/11/6 0006
     * @param parameMap
     * @return: retrofit2.Call<com.wx.wechat.response.WechatUser>
     */
    @GET("/sns/userinfo")
    Call<WeChatUser> oauth2getUserInfo(@QueryMap Map<String, String> parameMap);
    /**
     * @description: 验证AccessToken是否有效
     * @author: wx
     * @date: 2018/11/6 0006
     * @param accessToken
     * @param openId
     * @return: retrofit2.Call<Map<String,String>>
     */
    @GET("/sns/auth")
    Call<Map<String,String>> oauth2validateAccessToken(@Query(REQUEST_ACCESS_TOKEN) String accessToken,@Query(REQUEST_OPEN_ID) String openId);
    /**
     * @description: 微信小程序登录凭证校验(获取微信用户openid)
     * @author: wx
     * @date: 2018/11/6 0006
     * @param parameMap
     * @return: retrofit2.Call<com.wx.wechat.response.WeChatCode2Session>
     */
    @GET("/sns/jscode2session")
    Call<WeChatCode2Session> code2Session(@QueryMap Map<String, String> parameMap);
}
